#include "TransactionMQProducer.h"
#include "DefaultMQProducerImpl.h"
#include "TransactionCheckListener.h"

TransactionMQProducer::TransactionMQProducer()
	: m_pTransactionCheckListener(NULL),
	  m_checkThreadPoolMinSize(1),
	  m_checkThreadPoolMaxSize(1),
	  m_checkRequestHoldMax(2000)
{

}

TransactionMQProducer::TransactionMQProducer(const std::string& producerGroup)
	:DefaultMQProducer(producerGroup),
	 m_pTransactionCheckListener(NULL),
	 m_checkThreadPoolMinSize(1),
	 m_checkThreadPoolMaxSize(1),
	 m_checkRequestHoldMax(2000)
{

}

void TransactionMQProducer::start()
{
	m_pDefaultMQProducerImpl->initTransactionEnv();
	DefaultMQProducer::start();
}

void TransactionMQProducer::shutdown()
{
	DefaultMQProducer::shutdown();
	m_pDefaultMQProducerImpl->destroyTransactionEnv();
}

TransactionSendResult TransactionMQProducer::sendMessageInTransaction(Message& msg)
{
	return m_pDefaultMQProducerImpl->sendMessageInTransaction(msg);
}

void TransactionMQProducer::endTransaction(TransactionSendResult transactionSendResult,
						LocalTransactionState localTransactionState) 
{
	m_pDefaultMQProducerImpl->endTransaction(transactionSendResult, localTransactionState);
}

TransactionCheckListener* TransactionMQProducer::getTransactionCheckListener()
{
	return m_pTransactionCheckListener;
}

void TransactionMQProducer::setTransactionCheckListener(TransactionCheckListener* pTransactionCheckListener)
{
	m_pTransactionCheckListener = pTransactionCheckListener;
}

int TransactionMQProducer::getCheckThreadPoolMinSize()
{
	return m_checkThreadPoolMinSize;
}

void TransactionMQProducer::setCheckThreadPoolMinSize(int checkThreadPoolMinSize)
{
	m_checkThreadPoolMinSize = checkThreadPoolMinSize;
}

int TransactionMQProducer::getCheckThreadPoolMaxSize()
{
	return m_checkThreadPoolMaxSize;
}

void TransactionMQProducer::setCheckThreadPoolMaxSize(int checkThreadPoolMaxSize)
{
	m_checkThreadPoolMaxSize = checkThreadPoolMaxSize;
}

int TransactionMQProducer::getCheckRequestHoldMax()
{
	return m_checkRequestHoldMax;
}

void TransactionMQProducer::setCheckRequestHoldMax(int checkRequestHoldMax)
{
	m_checkRequestHoldMax = checkRequestHoldMax;
}